/*
 * SPDX-FileCopyrightText: 2023 XWiki CryptPad Team <contact@cryptpad.org> and contributors
 *
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

@import (reference) "../../customize/src/less2/include/framework.less";
@import (reference) "../../customize/src/less2/include/comments.less";
@import (reference) "../../customize/src/less2/include/tools.less";

body.cp-app-pad {
    .framework_main(
        @bg-color: @colortheme_apps[pad],
    );

    @bg-color: @cp_app-bg;
    @toolbar-bg-active: contrast(@cp_toolbar-bg, darken(@cp_toolbar-bg, 10%), lighten(@cp_toolbar-bg, 10%));


    display: flex;
    flex-flow: column;
    max-height: 100%;
    min-height: auto;

    #cp-app-pad-editor {
        flex: 1;
        display: flex;
        flex-flow: row;
        height: 100%;
        overflow: hidden;
       .cp-toolbar-chat-drawer, .cp-toolbar-userlist-drawer{
        @media screen and (max-width: @browser_media-medium-screen){
            position: absolute;
            right: 0;
            bottom: 0;
            top: 74px;

        }
       }
    }

    @media screen and (max-height: @browser_media-medium-screen),
           screen and (max-width: @browser_media-medium-screen) {
        #cp-app-pad-toc {
            margin: 5px;
            &.hidden {
                margin: 1px;
            }
        }
        #cp-app-pad-comments {
            .cp-pad-show, .cp-pad-hide {
                display: none;
            }
        }
    }

    #cp-app-pad-toc, #cp-app-pad-comments, #cp-app-pad-resize {
        .cp-pad-show, .cp-pad-hide {
            position: absolute;
            cursor: pointer;
            height: 28px;
            line-height: 28px;
            padding: 0px 6px;
        }
        &.hidden {
            width: auto !important;
            .cp-pad-show {
                position: relative;
            }
            & > :not(.cp-pad-show) {
                display: none;
            }
        }
        &:not(.hidden) {
            .cp-pad-show { display: none; }
        }
    }
    #cp-app-pad-toc {
        .cp-pad-show {
            line-height: 25px;
        }
    }
    #cp-app-pad-comments {
        &.hidden {
            .cp-pad-show.notif {
                color: @cp_comments-notif;
                border-color: @cryptpad_color_red;
            }
        }

        .cp-pad-show {
            line-height: 0px;
        }
    }
    #cp-app-pad-resize {
        order: 2;
        position: relative;
        height: 28px;
        width: 26px;
        margin-left: 10px;
        margin-top: 10px;
        margin-right: 0px;
        button {
            color: @cp_pad-fg;
            border-color: @cp_pad-fg;
        }
    }
    #cp-app-pad-toc {
        @toc-level-indent: 15px;

        overflow-y: auto;
        margin-top: 10px;
        margin-left: 10px;
        margin-right: 10px;
        width: 200px;
        color: @cp_pad-fg;
        //color: @cryptpad_text_col;
        position: relative;
        .cp-pad-show, .cp-pad-hide {
            right: 0;
        }
        h2 {
            font-size: 1.5rem;
        }
        p {
            margin-bottom: 5px;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
            a {
                color: @cp_pad-fg;
            }
            &.cp-pad-toc-2 {
                margin-left: @toc-level-indent;
            }
            &.cp-pad-toc-3 {
                margin-left: @toc-level-indent * 2;
            }
        }
    }
    #cp-app-pad-comments {
        order: 3;
        width: 330px;
        //background-color: white;
        margin: 10px;
        position: relative;
        .cp-pad-show, .cp-pad-hide {
            left: 0;
        }
        h2 {
            font-size: 1.5rem;
            text-align: center;
        }
        .comments_main();
    }
    .cp-app-pad-comments-modal {
        display: flex;
        flex-flow: column;
        max-height: 100%;
        h2 {
            text-align: left;
        }
        p.msg{
            align-self: center;
            padding: 0;
        }
        .dialog.nav{
            padding: 10px;
        }
    }

    .cke_toolbox_main {
        background-color: @cp_toolbar-bg;
        color: @cp_toolbar-fg;
        .cke_toolbar {
            height: 28px;
            padding: 2px 0;
            display: flex;
        }
        .cp-app-pad-wordCount {
            float: right;
            display: inline-flex;
            height: 24px;
            align-items: center;
            padding: 4px;
            color: @cryptpad_text_col;
        }
        .cke_button__print {
            display: none !important;
        }
        .cke_combo_on .cke_combo_button {
            background-color: @toolbar-bg-active;
            border-color: @toolbar-bg-active;
        }
        .cke_button, .cke_combo_button {
            .cke_combo_open{
                display: flex;
                flex-flow: row;
                .cke_combo_arrow{
                    @media (max-width: 360px){
                        display:none;
                    }
                }
            }
            .tools_unselectable();
            &.cke_button_on, &.cke_combo_button:hover, &.cke_button_off:hover {
                background-color: @toolbar-bg-active;
                border-color: @toolbar-bg-active;
            }
            .cke_combo_text {
                color: @cp_toolbar-fg;
            }
            .cke_button_icon {
                filter: @cp_pad-icon-filter;
            }
        }
    }
    .cke_wysiwyg_frame {
        width: 100%;
    }
    #cke_editor1 {
        display: flex;
        flex-flow: column;
        height: 100%;
        border: 0;
        flex: 1;
        > .cke_inner {
            overflow: hidden;
            flex: 1;
            position: unset;
            display: flex;
            flex-flow: column;
            margin-top: -1px;
        }
        #cke_1_top {
            display: none;
        }
    }
    #cke_1_contents {
        svg {
            margin: 0;
        }
        flex: 1;
        display: flex;
        height: auto !important;
        background-color: @bg-color;
        justify-content: center;
        iframe {
            background-color: transparent;
            flex: 1;
            min-width: 0;
            order: 1;
        }
        div.cp-comment-bubble {
            position: relative;
            button {
                position: absolute;
                padding: 0 4px;
                background: @cp_toolbar-bg;
                margin-left: 0px;
                margin-top: 20px;
                line-height: unset;
                &:hover {
                    background: @toolbar-bg-active;
                }
            }
        }
        &.cke_body_width {
            div.cp-comment-bubble {
                button {
                    margin-left: 30px;
                }
            }
            iframe {
                margin: 0 30px;
                max-width: 800px;
            }
        }
    }

    .cke_dialog {
        display: block;
        overflow-x: auto;
        max-height: 100vh;
        .cke_dialog_contents {
            #ck-mediatag-preview {
                margin: auto;
                resize: both;
                max-width: 300px;
                max-height: 300px;
                overflow: auto;
            }
            media-tag {
                display: flex;
                border-style: solid;
                border-color: black;
            }
        }
    }

    .cke_wysiwyg_frame {
        min-width: 60%;
    }

    .cp-pad-settings-dialog {
        .cp-pad-settings-radio-container {
            display: flex;
            align-items: center;
            .cp-radio, &>button {
                margin-right: 20px;
            }
            margin-bottom: 20px;
            svg {
                margin: 0;
            }
        }
        .cp-app-prop-content {
            margin-bottom: 0;
        }
    }

    @media print {
        #cke_1_top {
            display:none !important;
        }
        &.cp-app-pad .cp-toolbar-userlist-drawer {
            display:none;
        }
    }
}
